OOP - Assignment 3
Topic: A
Date Data-type
Points: 25
Due: 2-5-2001
Instructor: Dana
Steil
Files:
Assignment3.cpp
Date.cpp
Date.h
Create a class to represent a date with the following functionality:
- Create
a function to output the date in all of the following 3 formats
- DDD
YYYY- 288 2000
- MM/DD/YYYY
- 10/14/2000
- Month
Day, YYYY – October 14, 2000
- Use a
static member variable to keep track of which of the above formats to use
when showing the date.
- Supply
a static member function to modify the static out-put formatting
variable. This function should
accept a (string or c-style string) parameter containing an example of the
desired out-put format. Be sure to
consider what to do if it does not match any of the available formats.
- Create
a default constructor that initializes the date’s member variables
according to the system date.
Using the standard library functions of the <ctime> header.
- Create
a constructor allowing date objects to be initialized with dates of the
formats shown above. This constructor
should accept a (string or c-style string) parameter containing the new
date in one of the prescribed formats.
Be sure to consider what to do if it does not match any of the
available formats
- Create
a get member function that will allow the user to enter the date in any of
the formats shown above. This
function should validate the input.
- Create
a function that will show the difference between two dates. You can pick one of the following
formats to report this value: days
only, days and months, or days, moths and years. Again you are only required to pick one of theses
formats. This function should
take a CDate as a parameter then report the difference between itself and
that date.
Test Program
Write a test program that verifies that each of the
requirements above is complete. Your
test program must be thorough. Your
test program does not have to interact with the user.
Leap Years
if (year mod 4 != 0)
{use 28 for days in February}
else if (year mod 400 == 0)
{use 29 for days in February}
else if (year mod 100 == 0)
{use 28 for days in February}
else
{use 29 for days in February}